package com.cet.designpatterns.state;

/**
 * @program: algorithm
 * @description: 发放奖品状态
 * @author: 陈恩涛
 * @create: 2021-09-26 23:15
 **/
public class DispenseState extends State {

    private RaffleActivity activity;

    public DispenseState(RaffleActivity activity) {
        this.activity = activity;
    }

    @Override
    public void deductPoints() {
        System.out.println("不能扣除积分！");
    }

    @Override
    public boolean raffle() {
        System.out.println("不能抽奖");
        return false;
    }

    @Override
    public void dispensePrize() {
        if (activity.getCount() > 0) {
            System.out.println("恭喜您中奖了！");
            activity.setState(activity.getNoRafflleState());
        } else {
            System.out.println("很抱歉，奖品已经发放完了！");
            activity.setState(activity.getDispensOutState());
        }
    }
}
